#!/usr/bin/env python3

# version 1
def selection1(in_list):
    temp = None
    index = None
    sorted_list = []
    list_s = len(in_list)
    for i in range(list_s):
        temp = in_list[0]
        index = 0
        for j in range(1, len(in_list)):
            if temp < in_list[j]:
                temp = in_list[j]
                index = j
        sorted_list.append(temp)
        in_list.remove(temp)
    
    return sorted_list

# version 2
def smallest(arr):
    v = arr[0]
    index = 0
    for i in range(len(arr)):
        if v > arr[i]:
            v = arr[i]
            index = i
    return index

def selection2(arr):
    new_arr = []
    for i in range(len(arr)):
        index = smallest(arr)
        new_arr.append(arr.pop(index))
    return new_arr

# version 1
la = [1, 23, 17, 65, 12, 29, 34]
la2 = [1, 23, 17, 65, 12, 29, 34]
lb = selection1(la)
print(lb)

# version 2
lb = selection2(la2)
print(lb)
